1 // arcade controller thing
2 // Copyright (c) 2017 Clinton Ebadi <clinton@unknownlamer.org>
3 // GPLv3 or (at your option) any later version
4 // .. insert license text here ...
8 // - screw holes + captive nut to mount
9 // - internal mount for mcu and battery
10 // - hole for usb panel mount
14 // - wire routing clips on panel?
15 // - buttons on side for pinball?
16 // - vent under mcu/battery?
17 // - slant panel toward player?
20 // - hinge is not aligned -- either male arm length or connector placement is wrong
22 use <obiscad/bcube.scad>
23 use <obiscad/bevel.scad>
24 use <obiscad/attach.scad>
31 rotate ([-10, 0, 0]) translate ([0, 0, box_depth+20]) panel ();
33 for (i = [2 ,4]) translate ([panel_width+hinge_joint_width*i, 0, 0]) hinge_male ();
41 panel_bevel = 2; // fixme: calculate based on box_base_thickness?
45 box_base_thickness = 5;
47 $button_d = 30; // I think this should be special
53 hinge_arm_thickness = 6;
54 hinge_arm_length = 50;
56 // size of block to cut female connector from
57 hinge_base_size = [hinge_arm_width * 2, hinge_arm_thickness * 2, hinge_arm_thickness * 2];
59 hinge_x_offset = 15; // distance from side of case
62 // gunk that should be elsewhere...
63 // bcube parameters, clean up
67 // switch to hide panel in previews
72 module button (bezel = $button_d+4) {
81 for (x = [-joystick_width/2, joystick_width/2], y = [-joystick_height/2, joystick_height/2]) {
82 translate ([x, y, 0]) circle (d=bolt_d); // need slot instead
84 circle (d=center_hole_d);
85 %square ([joystick_width, joystick_height], center=true); // not right...
91 module case_base (width=panel_width, height=panel_height, d=box_base_thickness) {
92 bcube([width, height, d], cr, cres);
95 module case_walls () {
99 bcube([panel_width, panel_height, box_depth-box_base_thickness], cr, cres);
100 bcube([panel_width-box_wall*2, panel_height-box_wall*2, box_depth+1], cr, cres); // FIXME: does this accidentally cut some of the bottom out?
102 attach (case_connector_wall ([panel_width/2-hinge_x_offset, -box_wall+0.01, box_depth/2]), hinge_connector_back (h=hinge_base_size[2]+(hinge_arm_thickness+panel_bevel)/2)) hinge_female_base (support=true);
103 attach (case_connector_wall ([-panel_width/2+hinge_x_offset, -box_wall+0.01, box_depth/2]), hinge_connector_back (h=hinge_base_size[2]+(hinge_arm_thickness+panel_bevel)/2)) hinge_female_base (support=true);
105 attach (case_connector_wall ([panel_width/2-hinge_x_offset, -box_wall+0.01, box_depth/2]), hinge_connector_back (h=hinge_base_size[2]+(hinge_arm_thickness+panel_bevel)/2)) hinge_female_cut ();
106 attach (case_connector_wall ([-panel_width/2+hinge_x_offset, -box_wall+0.01, box_depth/2]), hinge_connector_back (h=hinge_base_size[2]+(hinge_arm_thickness+panel_bevel)/2)) hinge_female_cut ();
108 %connector (case_connector_wall ([panel_width/2-hinge_x_offset, -box_wall+0.01, box_depth/2]));
113 translate ([0, 0, box_depth/2]) case_walls ();
118 // specify which wall (rear, front, left, right). vector addition may help...
119 // offset from center of wall, as vector (and use vector subtraction!)
120 // optional: inside/outside
121 CASE_WALL_BACK = [0, panel_height/2, -box_base_thickness/2];
123 function case_connector_wall (offset=[0,0,0], wall=CASE_WALL_BACK) = [ wall + offset, [0, -1, 0], 0 ];
128 // allow override of global base dimensions
130 // maybe: add connector for pin to socket so that can easily be test
131 // fit in software for a nicer preview
133 function hinge_connector_back (th=hinge_arm_thickness*2, h=hinge_base_size[2]) = [ [0, th/2, h/2], [0,1, 0], 0 ];
134 function hinge_connector_bottom (th=hinge_arm_thickness*2, h=hinge_base_size[2]) = [ [0, 0, -h/2], [0, 0, 1], 0 ];
137 // gusset support underneath (with argument to toggle)
139 module hinge_female_base (support=false) {
140 // %connector (hinge_connector_back ());
141 // %connector (hinge_connector_bottom ());
142 color ([0.5,0.3,0.1, 0.3]) cube (hinge_base_size, center=true);
145 corner = [ [ 0, hinge_base_size[1]/2, -hinge_base_size[2]/2], [ 0, -1, -1 ], 0];
146 base_a = [ [0, hinge_base_size[1]/2, -hinge_base_size[2]/2], [1, 0, 0], 0];
149 // fixme: calculate actual radius
150 color ([0.5,0.7,0.1, 0.3]) bconcave_corner_attach(base_a, corner , l=hinge_base_size[1], cr=hinge_base_size[0],cres=0, ext_corner=false, th=0);
154 module hinge_female_cut () {
155 joint_male_negative (male_joint_width=hinge_arm_width,
156 male_joint_thickness=hinge_arm_thickness,
159 male_joint_height=hinge_arm_length);
162 module hinge_female (support=false) {
164 hinge_female_base (support);
169 module hinge_male () {
170 for (i=[0,1]) mirror ([0, i, 0]) translate ([0, -hinge_arm_length/4, 0])
171 joint_male (male_joint_width=hinge_arm_width,
172 male_joint_thickness=hinge_arm_thickness,
173 male_joint_height=hinge_arm_length/2,
180 // fixme: when attachment axis is [0, 0, -1] something makes the math
181 // go funky and the connector is facing upward, adding very slight y
182 // misalignment "fixes" it...
183 PANEL_BOTTOM = [ [ 0, 0, -box_base_thickness/2+0.01 ], [ 0, 0.000000000001, -1 ] ];
184 PANEL_TOP = [ [ 0, 0, box_base_thickness/2-0.01 ], [ 0, 0, 1 ] ];
186 function panel_connector (offset=[0,0,0], wall=PANEL_BOTTOM) = [ wall[0]+offset, wall[1], 0 ];
192 translate ([0, 0, panel_bevel/2]) {
193 case_base (d=box_base_thickness-panel_bevel);
195 case_base (width=panel_width-box_wall*2-0.1, height=panel_height-box_wall*2-0.1);
198 linear_extrude (box_base_thickness*2,center=true) panel_layout ();
202 attach (panel_connector (offset=[panel_width/2-hinge_x_offset, panel_height/2-hinge_arm_length, 0]),
203 hinge_connector_bottom ()) hinge_female ();
204 attach (panel_connector (offset=[-panel_width/2+hinge_x_offset, panel_height/2-hinge_arm_length, 0]),
205 hinge_connector_bottom ()) hinge_female ();
208 module panel_attach (position, angle=0) {
211 c1 = [ [x, y, box_base_thickness/2], [0,0,1], angle ];
212 a1 = [ [0,0, 0], [0,0,0], 0 ];
213 // %connector (c1); // fixme: don't use 2d for layout
214 attach (c1, a1) children ();
217 // panel layout inspired by the Neo Geo layout
218 module panel_layout () {
219 translate ([-panel_width/2 + 40, 0, 0]) {
220 panel_attach ([0, 0], 90) joystick ();
222 // p1, coin (floating off in the distance...)
223 translate ([140, 0, 0]) {
225 for (x = [0, $button_d+10]) {
226 panel_attach ([x, 42]) button ();
231 translate ([60, -20, 0]) {
232 panel_attach ([0, 0]) button ();
233 for (i = [ 1 : 3 ]) {
234 panel_attach ([i*($button_d+10)-10, $button_d]) button ();